package org.tis.tools.abf.module.jnl.controller;

import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.tis.tools.abf.module.jnl.feign.ILogOperateAbfFeignService;
import org.tis.tools.model.common.ResultVO;
import org.tis.tools.model.log.LogOperate;
import org.tis.tools.starter.mybatisplus.querykit.model.Query;

import javax.validation.constraints.NotBlank;

/**
 * Created by chenchao
 * Created on 2018/9/1 10:19
 */
@RestController
@RequestMapping("/logOperate")
@Validated
public class LogOperateController{

    @Autowired
    private ILogOperateAbfFeignService logOperateAbfFeignService;

    @ApiOperation(value = "分页查询操作日志",notes = "传分页数据(page),筛选条件(condition)作为参数")
    @PostMapping("/list")
    public ResultVO list(@RequestBody @Validated Query<LogOperate> query) {
        return logOperateAbfFeignService.list(query);
    }

    @ApiOperation(value = "根据GUID查询操作日志",notes = "传入guid作为参数")
    @GetMapping("/{id}")
    public ResultVO detail(@PathVariable @NotBlank(message = "guid不能为空") String id) {
        return logOperateAbfFeignService.detail(id);
    }

    @ApiOperation(value = "根据操作员分页查询操作日志",notes = "传入分页数据(page),操作员(userId)作为参数")
    @PostMapping("/operator")
            public ResultVO listByUser(@RequestBody @Validated Query<LogOperate> query) {
        return logOperateAbfFeignService.listByUser(query);
    }

}
